package com.example.mapper;
import com.example.pojo.Reg_Pojo;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;
import java.util.List;

@Mapper
public interface RegMapper {

    @Select("SELECT id, Name, Tel, DepartID FROM Reg")
    List<Reg_Pojo> listAll();

    @Select("SELECT id, Name, Tel, DepartID FROM Reg WHERE id = #{id}")
    Reg_Pojo getById(@Param("id") Integer id);

    @Insert("INSERT INTO Reg (Name, Tel, DepartID) VALUES (#{Name}, #{Tel}, #{DepartID})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Reg_Pojo reg);

    @Update("UPDATE Reg SET Name = #{Name}, Tel = #{Tel}, DepartID = #{DepartID} WHERE id = #{id}")
    void update(Reg_Pojo reg);

    @Update("DELETE FROM Reg WHERE id = #{id}")
    void delete(@Param("id") Integer id);
}
